const scriptTag = document.querySelector('script[chat-bot-code]');
const scriptWith = scriptTag.getAttribute('chat-bot-width') ? scriptTag.getAttribute('chat-bot-width') : '400px';
const scriptHeight = scriptTag.getAttribute('chat-bot-height') ? scriptTag.getAttribute('chat-bot-height') : '600px';
const code = scriptTag.getAttribute('chat-bot-code');
const baseUrl = scriptTag.getAttribute('chat-bot-url');
const chatBox = document.createElement('div');
const domain = location.hostname;
chatBox.innerHTML = `
  <div id="aidogChatMain" style="display:none;width: ${scriptWith}; background: #fff; border-radius: 10px; box-shadow: 0px 0px 40px rgba(0,0,0,.1); border-radius: 10px; overflow: hidden; position: fixed; bottom: 30px; right: 30px;z-index: 99999999;">
        <div  style="display: flex; align-items: center; justify-content: flex-end; background: #2563eb; padding: 0 16px;">
            <div  style="width: 36px; height: 36px; position: absolute; top: 8px; border-radius: 100%; display: flex; align-items: center; justify-content: center; background: #0040c1; cursor: pointer;"
                  onclick="aidogChatMain.style.display='none';aidogChatLogo.style.display='block';">
                <img style=" height: 12px;" src="/img/closeon.svg"/>
            </div>
        </div>
        <div style="display: flex; align-items: center;">
            <iframe src="${baseUrl}/#/alRobot/chat/chat?code=${code}&domain=${domain}" width="100%" height="${scriptHeight}"  style="border: none;"></iframe>
        </div>
    </div>

    <div id="aidogChatLogo"
            style="user-select: none; cursor: pointer; position: fixed; right: 30px; z-index: 99999999;bottom: 30px; cursor: pointer;"
            onclick="aidogChatLogo.style.display='none';aidogChatMain.style.display='block';"
    >
        <div style="width: 55px; height: 55px; border-radius: 100%; background: #2360e4; display: flex; align-items: center; justify-content: center;"><img style="height: 21px;"  src="/img/logoon.png"/></div>
    </div>
`;
document.body.appendChild(chatBox);